<template>
<div>
  <van-nav-bar
      title="爱尔眼科"
      style="background-color: #36c14c"
      left-text="返回"
      left-arrow
      @click-left="$router.go(-1)"
    >
    </van-nav-bar>
    <div v-if="DetailsData" class="newsDetailsBox">
    <div class="newsTop">
      <h2>{{ DetailsData.title }}</h2>
      <p>
        发布日期:{{
          moment(parseInt(DetailsData.releaseTime)).format("YYYY-MM-DD")
        }}
      </p>
    </div>
    <div v-html="content"></div>
  </div>
</div>
</template>

<script>
export default {
  data() {
    return {
      DetailsData: null,
      content: "",
    };
  },
  mounted() {
    this.getNewsData();
  },
  methods: {
    getNewsData() {
      let routeParmas = this.$route.params.id;
      let args = `id=${routeParmas}`;
      // let url = `/news/details/${routeParmas.id}`;
      this.axios.post("/news/details", args).then(res => {
        console.log(res);
        this.DetailsData = res.data.data[0];
        this.content = res.data.data[0].content;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.newsDetailsBox {
  padding: 0 16px;
  .newsTop {
    h2 {
      color: #01c6af;
    }
    p {
      font-size: 14px;
      color: #666;
      text-align: right;
    }
  }
}
::v-deep .van-nav-bar__title {
  color: #fff;
}
::v-deep .van-nav-bar__text {
  color: #fff;
}
::v-deep .van-icon {
  color: #fff;
}
</style>
